<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" media="screen" href="css/base.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="css/head.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="css/addCustomer.css" />
</head>
<body>
<div class="mian-head">
    <div class="mian-head-mid">
        <p class="main-title">客户管理系统</p>
        <div class="mian-head-mid-r">
            <p class="main-hy" th:text="'欢迎：'+${session.myUser.name}+'管理员'"></p>
            <div class="mian-head-mid-r-slpi"></div>
            <p><a th:href="@{getUserMessage(name=${session.myUser.name})}">个人信息</a></p>
            <div class="mian-head-mid-r-slpi"></div>
            <p><a href="logout">退出</a></p>
        </div>
    </div>
</div>
<div class="list-mid">
    <!-- 标题 -->
    <div class="list-title">
        <div class="list-title-div"></div>
        <a href="GetCustomerList?pageCur=1"><p>添加客户</p>
        </a>
    </div>
    <!-- 表单 -->
    <form name="insertCForm" action="insertCustomer" method="post" onsubmit="return checkfun()">
        <table class="addform-table">
            <tr>
                <td class="addform-1">姓名：</td>
                <td class="addform-2"><input class="addform-input-text" type="text"  id="name" name="name"  required="required" /></td>
            </tr>
            <tr>
                <td class="addform-1">负责人编号：</td>
                <td class="addform-2">
                    <select name="user_id" class="addform-input-text"  required="required" >
                        <option value="">--请选择--</option>
                            <option th:each="u:${users}" th:value="${u.id}" th:text="${u.id}"></option>
                    </select>
                </td>
            </tr>

            <input class="addform-input-text" type="hidden"  name="create_id" th:value="${session.userId}"/>
            <tr>
                <td class="addform-1">行业：</td>
                <td class="addform-2"><select name="industry" class="addform-input-text"  required="required" >
                    <option value="">--请选择--</option>
                    <option value="餐饮">餐饮</option>
                    <option value="房地产">房地产</option>
                    <option value="服务">服务</option>
                    <option value="公益组织">公益组织</option>
                    <option value="教育">教育</option>
                    <option value="计算机">计算机</option>
                    <option value="金融">金融</option>
                    <option value="政府机关">政府机关</option>
                    <option value="农业">农业</option>
                    <option value="旅游业">旅游业</option>
                    <option value="媒体">媒体</option>
                    <option value="其他">其他</option>
                </select></td>
            </tr>
            <tr>
                <td class="addform-1">等级：</td>
                <td class="addform-2">
                    <input type="radio" name="level" value="普通客户"  required="required" />普通客户
                    <input type="radio" name="level" value="VIP客户"  required="required" />VIP客户
                </td>
            </tr>
            <tr>
                <td class="addform-1">固定电话：</td>
                <td class="addform-2">
                    <input class="addform-input-text" type="text" id="text"  name="phone"  required="required"  />
                </td>
            </tr>
            <tr>
                <td class="addform-1">移动电话：</td>
                <td class="addform-2"><input class="addform-input-text" id="mobile" type="text"  name="mobile"  required="required" /></td>
            </tr>
            <tr>
                <td class="addform-1">地址：</td>
                <td class="addform-2"><input class="addform-input-text" id="address" type="text"  name="address"  required="required" /></td>
            </tr>
            <tr>
                <td colspan="2" class="addform-submit"> <input onclick="checkfun()" type="submit" value="提交" /><a class="returnbtm" href="GetCustomerList">返回</a></td>
            </tr>
        </table>

    </form>

</div>

<script>
    function checkfun() {
        var name=document.forms["insertCForm"]["name"].value;
        var phone=document.forms["insertCForm"]["phone"].value;
        var mobile=document.forms["insertCForm"]["mobile"].value;
        var address=document.forms["insertCForm"]["address"].value;
        //姓名不能超过10个字符
        if(name.length > 10){
            alert("姓名不能超过10个字符");
            return false;
        }
        var isphone = /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/;
        var ismobile = /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
        console.log(isphone.test(phone));

        if(phone != "" && !isphone.test(phone)){
            alert("固定电话号码输入不合法");
            return false;
        }
        if(mobile != "" && !ismobile.test(mobile)){
            alert("移动电话号码输入不合法");
            return false;
        }
    }
</script>
</body>
</html>
